<template>
  <el-container class="main_con">
    <div class="filter_con ds_block">
      <!-- <div class="button_area"><el-button v-has size="medium" type="primary" @click="adduser">新增管理员</el-button></div> -->
      <div class="filter_area">
         <label class="mr_15 mt_15">订单编号</label>
        <el-input size="medium" v-model="params.order_id" class="serach_input mr_15 mt_15" style="width:300px;" placeholder="订单编号"></el-input>
        <!-- <el-input size="medium" v-model="params.mobile" class="serach_input mr_15 mt_15" placeholder="手机号码"></el-input>
        <date-picker size="medium" @change="gettime" class="mr_15 mt_15"></date-picker> -->
        <el-button size="medium" @click="search">搜索</el-button>
      </div>
    </div>
    <div class="list_con">
      <el-table @selection-change="SelectHadnle" :data="list" element-loading-text fit highlight-current-row class="main-loading">
        <el-table-column prop="order_no" label="订单编号"></el-table-column>
        <el-table-column prop="money" label="变更金额">

          <template slot-scope="scope">
            <span
              class="add"
              v-if="scope.row.type == 0"
              >+{{ scope.row.money }}</span
            >
            <span
              class="reduce"
              v-if="scope.row.type == 1"
              >-{{ scope.row.money }}</span
            >
          </template>
        </el-table-column>
        <el-table-column prop="old_money" label="变更前金额"></el-table-column>
        <el-table-column prop="new_money" label="变更后金额"></el-table-column>

        <!-- <el-table-column prop="status_text" label="状态"></el-table-column> -->
        <el-table-column prop="time" label="变更时间"></el-table-column>
        <!-- <el-table-column label="操作">
          <template slot-scope="scope">
            <el-button v-has v-if="scope.row.is_root != 1" type="text" @click="EditHandle(scope.row.id)">编辑</el-button>
            <el-button v-has v-if="scope.row.is_root != 1" type="text" @click="EnableHandle(scope.row)">{{ scope.row.status == 1 ? '禁用' : '启用' }}</el-button>
            <el-button v-has v-if="scope.row.is_root != 1" type="text" @click="handleClose(scope.row.id)">删除</el-button>
          </template>
        </el-table-column> -->
      </el-table>
      <div class="table_footer">
        <!--  <el-button size="medium">批量删除
        </el-button>-->
        <el-pagination
          @current-change="ChangeCurrent"
          class="pages"
          background
          layout="prev, pager, next"
          :total="total"
          :page-size="size"
          :page-count="page"
          hide-on-single-page
        ></el-pagination>
      </div>
    </div>
  </el-container>
</template>

<script>
import {mapGetters} from 'vuex';
import {changeMoneyList} from '@/api/shop/order';

import DatePicker from '@/components/DatePicker/index';
import {fitter_keyword} from '@/utils/index';
export default {
  data() {
    return {
      params: {
        order_id: '',
        page: 1,
        size: 10
      },
      paramsdf: {},
      page: 1,
      size: 10,
      total: 0,
      listLoading: true,
      list: [],
      drawer: false,
      direction: 'rtl',
      user_id: '',
      user_type: 'add',
      selectionData: [],
      url: ''
    };
  },

  computed: {
    ...mapGetters(['allroleslist'])
  },
  mounted() {
    if (this.$route.query.id) {
      this.params.order_id = this.$route.query.id;
    }
    this.getlist();
  },
  filters: {
    filter_role(s, list) {
      var d = list.filter(a => {
        return a.id == s;
      });
      if (d.length > 0) {
        return d[0].name;
      } else {
        return '没有该角色';
      }
    }
  },
  methods: {
    search() {
      // this.paramsdf = fitter_keyword(this.params);
      this.getlist();
    },

    //获取列表
    getlist() {
      this.listLoading = true;
      var data = this.params;
      changeMoneyList(data).then(res => {
        var jsondata = res.msg;
        this.list = jsondata.data;
        this.total = jsondata.total;
        // this.list = response.data.items
        this.listLoading = false;
      });
    },
    //获取时间
    gettime(value) {
      this.params.begin_date = value[0];
      this.params.end_date = value[1];
    },
    //切换页码
    ChangeCurrent(page) {
      this.params.page = page;
      this.getlist();
    }
  }
};
</script>

<style lang="scss" scoped>
.login_url {
  padding: 8px 16px;
  background-color: #f4f4f5;
  color: #909399;
  box-sizing: border-box;
  border-radius: 4px;
  display: flex;
  align-items: center;
  font-size: 14px;
  p {
    margin: 0;
    margin-right: 10px;
  }
  .el-button {
    padding: 0;
  }
}
.add {
  color: #ff1f2c;
  font-weight: bold;
}
.reduce {
  color: #19be6b;
  font-weight: bold;
}
</style>
